package tech.ezrealc.fall2023.configuration;

import jakarta.annotation.Resource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.handler.MappedInterceptor;
import tech.ezrealc.fall2023.interceptor.TokenInterceptor;


@Configuration
@ComponentScan("tech.ezrealc.fall2023")
@EnableWebMvc
@EnableTransactionManagement
public class SpringConfig {

    @Resource
    private TokenInterceptor tokenInterceptor;

    @Bean
    public MappedInterceptor sessionInterceptor () {
        return new MappedInterceptor(
                new String[]{"/**"},
                new String[]{"/api/session"},
                tokenInterceptor);
    }

}
